package operation;


import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class AddOperation implements IOperation{
    public void work(BookList booklist) {
        System.out.println("新增图书");
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你要增加的书名");
        String name=scanner.nextLine();
        System.out.println("请输入作者");
        String author=scanner.nextLine();
        System.out.println("请输入类型");
        String type=scanner.nextLine();
        System.out.println("请输入价格");
        int price=scanner.nextInt();
        Book book=new Book(name,author,price,type);
        for (int i = 0; i < booklist.getsize(); i++) {
            if(booklist.getbook(i).getName().equals(name)) {
                System.out.println("已有这本书，不能重复添加");
                return;
            }
        }
        booklist.setBook(book);
        booklist.setsize(booklist.getsize()+1);
        System.out.println("aa");
    }
}
